package com.mc.algorithm;

public class Fibo {
	public static long value(int n){
		if(n==0)
			return 0;
		if(n==1)
			return 1;
		return value(n-1)+value(n-2);
	}
	
	public static long loop(int n){
		if(n==0)
			return 0;
		if(n==1)
			return 1;
		long n1=1;
		long n2=0;
		long result = 0;
		for(int i=0;i<n-1;i++){
			result = n1+n2;
			n2=n1;
			n1=result;
		}
		return result;
	}
	public static void main(String[] args) {
		System.out.println(Fibo.value(2));
		System.out.println(Fibo.loop(2));
	}
}
